﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace JKDD.Patient
{
    public partial class patientLogin : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string hospital = txtHospital.Text.ToString();
            string sections = txtSections.Text.ToString();
            string doctor = txtDoctor.Text.ToString();
            string sql,sql1;
            try
            {
                if (rbYes.Checked)
                {
                    if (doctor.Trim().Length > 0)
                    {
                        sql = "select * from TB_DOCTOR_INFO where SREGISTERID=" + doctor;
                        sql1 = "select * from TB_DOCTOR_INFO where SNAME='" + doctor + "' and SHOSIPITAL like '%" + hospital + "%' and SSECTIONS like '%" + sections + "%'";
                        DataTable dt, dt1;
                        dt = operateDB.GetDataTable(sql);
                        if (dt.Rows.Count > 0)
                        {
                            Response.Redirect("patientIndex.aspx?doctorID=" + doctor);
                        }
                        else
                        {
                            if (hospital.Trim().Length > 0 && sections.Trim().Length > 0)
                            {
                                dt1 = operateDB.GetDataTable(sql1);
                                if (dt.Rows.Count > 0)
                                {
                                    Response.Redirect("patientIndex.aspx?doctorID=" + dt.Rows[0]["SREGISTERID"].ToString());
                                }
                                else
                                {
                                    lblError.Text = "对不起，你所查找的医生不存在！";
                                }
                            }
                            else
                            {
                                lblError.Text = "对不起，你所查找的医生不存在！";
                            }
                        }
                    }
                    else
                    {
                        lblError.Text = "就诊医生一项不能为空，请正确输入！";
                    }
                }
                else
                {
                    lblError.Text = "你拒绝了我们的服务条款！";
                }
            }
            catch(Exception ex)
            {
                lblError.Text = "对不起，服务器错误，暂不能进入！";
            }
        }
    }
}
